home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / modex32w.zip / VPAL.ASM < prev    next >
Assembly Source File  |  1995-02-21  |  2KB  |  100 lines

  1.         .386
  2.         locals
  3.         include w.inc
  4.  
  5. ; VGA 256 Colour Palette Manipulation Routines
  6. ; Handle single colours as well as buffered palette sets
  7.  
  8. ; Copyright (c) 1994 Kumanan Yogaratnam
  9. ; Released to FreeWare
  10.  
  11. PALWRIT equ     03c8h
  12. PALDATA equ     03c9h
  13. CRTREG  equ     03dah
  14.  
  15. parms1  struc
  16.         dd      2 dup (?)       ; pushed EBP and ret addr
  17. pbuf    dd      ?               ; ptr to palette buffer
  18. ends
  19.  
  20. parms2  struc
  21.         dd      2 dup (?)
  22. stpal   dd      ?
  23. numpal  dd      ?
  24. pbuf2   dd      ?
  25. ends
  26.  
  27.         @cseg
  28.  
  29. WaitSync macro
  30.         mov dx, CRTREG
  31. @@1:
  32.         in al, dx
  33.         test al, 08h
  34.         jz @@1
  35. @@2:
  36.         in al, dx
  37.         test al, 08h
  38.         jnz @@2
  39. endm
  40.  
  41. public  _SetAllPalette, _SetIndexedPalette
  42.  
  43. _SetAllPalette proc near
  44.         push ebp
  45.         mov ebp, esp
  46.         push esi
  47.  
  48.         mov esi, [ebp+offset (parms1).pbuf]
  49.         mov dx, PALWRIT                 ; setup palette write
  50.         mov al, 0
  51.         out dx, al
  52.         mov ecx, (256*3) shr 2          ; read in dwords
  53.  
  54.         WaitSync
  55.  
  56.         mov dx, PALDATA                 ; set component port
  57. @@go:
  58.         lodsd                           ; read 4 bytes at a time
  59.         out dx, al
  60.         mov al, ah
  61.         out dx, al
  62.         shr eax, 16                     ; move hi word to lo word
  63.         out dx, al
  64.         mov al, ah
  65.         out dx, al
  66.         loop @@go
  67.  
  68.         pop esi
  69.         pop ebp
  70.         ret
  71. endp
  72.  
  73. _SetIndexedPalette proc      near
  74.         push ebp
  75.         mov ebp, esp
  76.         push esi
  77.  
  78.         mov esi, [ebp+offset (parms2).pbuf2]
  79.         mov dx, PALWRIT                 ; setup pal write
  80.         mov eax, [ebp+offset (parms2).stpal]
  81.         out dx, al                      ; set start pal ent
  82.         mov ecx, [ebp+offset (parms2).numpal]
  83.  
  84.         WaitSync
  85.  
  86.         mov dx, PALDATA
  87. @@go:
  88.         lodsb
  89.         out dx, al
  90.         loop @@go
  91.  
  92.         pop esi
  93.         pop ebp
  94.         ret
  95. endp
  96.  
  97. ends
  98. end
  99.  
  100.